package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysMomentCollection;
import com.ruoyi.project.system.service.ISysMomentCollectionService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;


@RestController
@Api("用户收藏平台瞬间")
@RequestMapping("/system/collection")
public class SysMomentCollectionController extends BaseController
{
    @Autowired
    private ISysMomentCollectionService sysMomentCollectionService;

    /**
     * 查询用户收藏平台瞬间列表
     */
    @PreAuthorize("@ss.hasPermi('system:collection:list')")
    @ApiOperation("查询用户收藏平台瞬间列表")
    @GetMapping("/list")
    public TableDataInfo list(SysMomentCollection sysMomentCollection)
    {
        startPage();
        List<SysMomentCollection> list = sysMomentCollectionService.selectSysMomentCollectionList(sysMomentCollection);
        return getDataTable(list);
    }

    /**
     * 获取用户收藏平台瞬间详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:collection:query')")
    @ApiOperation("获取用户收藏平台瞬间详细信息")
    @GetMapping(value = "/{collectionId}")
    public AjaxResult getInfo(@PathVariable("collectionId") Long collectionId)
    {
        return AjaxResult.success(sysMomentCollectionService.selectSysMomentCollectionById(collectionId));
    }

    /**
     * 新增用户收藏平台瞬间
     */
    @PreAuthorize("@ss.hasPermi('system:collection:add')")
    @ApiOperation("新增用户收藏平台瞬间")
    @Log(title = "用户收藏平台瞬间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMomentCollection sysMomentCollection)
    {
        return toAjax(sysMomentCollectionService.insertSysMomentCollection(sysMomentCollection));
    }

    /**
     * 修改用户收藏平台瞬间
     */
    @PreAuthorize("@ss.hasPermi('system:collection:edit')")
    @ApiOperation("修改用户收藏平台瞬间")
    @Log(title = "用户收藏平台瞬间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMomentCollection sysMomentCollection)
    {
        return toAjax(sysMomentCollectionService.updateSysMomentCollection(sysMomentCollection));
    }

    /**
     * 删除用户收藏平台瞬间
     */
    @PreAuthorize("@ss.hasPermi('system:collection:remove')")
    @ApiOperation("删除用户收藏平台瞬间")
    @Log(title = "用户收藏平台瞬间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collectionIds}")
    public AjaxResult remove(@PathVariable Long[] collectionIds)
    {
        return toAjax(sysMomentCollectionService.deleteSysMomentCollectionByIds(collectionIds));
    }
}
